home *** CD-ROM | disk | FTP | other *** search
/ Star Trek Starfleet Academy Mini Omnipedia / MINI_OMNI.ISO / pc / omni_v2.dxr / 00379_Multiindex utilities.ls < prev    next >
Encoding:
Text File  |  1996-04-15  |  4.0 KB  |  151 lines

  1. global oIndexMediator, gNumofHits, gModeState, gCurrentEntryName, gStatusField, gFTsearchscope, gGlobalStepCount, gLocalStepCount
  2.  
  3. on hBuildFTfromEntries
  4.   hReportStatus("Building lookup map ")
  5.   set LmyitemK to 1
  6.   set Lmax to mGetThisItemsMax(oIndexMediator, LmyitemK)
  7.   set Lnewlist to [:]
  8.   sort(Lnewlist)
  9.   repeat with i = 1 to Lmax
  10.     put " " after field gStatusField
  11.     set Lthisname to mGetThisEntryName(oIndexMediator, gModeState, LmyitemK, i)
  12.     set Lthischar to char 1 of string(Lthisname)
  13.     set LthisItem to hConvertAlphaToItem(hCapitalize(Lthischar))
  14.     if LthisItem > 26 then
  15.       delete char 1 of Lthisname
  16.       delete char length(Lthisname) of Lthisname
  17.       set Lthischar to char 1 of string(Lthisname)
  18.       set LthisItem to hConvertAlphaToItem(hCapitalize(Lthischar))
  19.     end if
  20.     set LthisAttriblist to [0]
  21.     addProp(Lnewlist, Lthisname, LthisAttriblist)
  22.   end repeat
  23.   set gNumofHits to Lmax
  24.   setAt(mGetEntireMode(oIndexMediator, gModeState), LmyitemK, Lnewlist)
  25.   mUpdateLimitsList(oIndexMediator, #FoundSet, gNumofHits)
  26.   hReportStatus("Lookup complete...")
  27. end
  28.  
  29. on hConvertAlphaToItem pTheAlpha
  30.   set Litem to charToNum(string(pTheAlpha))
  31.   if Litem >= 65 then
  32.     set Litem to Litem - 64
  33.   else
  34.     set Litem to value(pTheAlpha)
  35.   end if
  36.   return Litem
  37. end
  38.  
  39. on hConvertItemtoAlpha pItem, pMode
  40.   if gModeState = #CHRO then
  41.     return pItem
  42.   else
  43.     if gModeState = #EPISSUB then
  44.       return string(pItem)
  45.     else
  46.       if gModeState = #FoundSet then
  47.         if gFTsearchscope = #CHRO then
  48.           return pItem
  49.         else
  50.           if gFTsearchscope = #ALL then
  51.             if voidp(pMode) then
  52.               set Lmode to hGetMode(gCurrentEntryName)
  53.             else
  54.               set Lmode to pMode
  55.             end if
  56.             if Lmode = #CHRO then
  57.               return pItem
  58.             end if
  59.             set pItem to pItem + 64
  60.             set Lalpha to numToChar(pItem)
  61.           else
  62.             set pItem to pItem + 64
  63.             set Lalpha to numToChar(pItem)
  64.           end if
  65.         end if
  66.       else
  67.         set pItem to pItem + 64
  68.         set Lalpha to numToChar(pItem)
  69.       end if
  70.     end if
  71.   end if
  72.   return Lalpha
  73. end
  74.  
  75. on hConstructFieldName pWhatItem, pMode
  76.   if pMode <> #CHRO then
  77.     set pWhatItem to hConvertItemtoAlpha(pWhatItem, pMode)
  78.   end if
  79.   return "ATTRIB_" & pWhatItem & "_" & string(pMode)
  80. end
  81.  
  82. on hExtractAlphaItem PThisStr
  83.   set Lcurr to value(char 8 to 9 of PThisStr)
  84.   if integerp(Lcurr) then
  85.     return Lcurr
  86.   else
  87.     set Lcurr to char 8 of PThisStr
  88.     if integerp(value(Lcurr)) then
  89.       return value(Lcurr)
  90.     else
  91.       set Lcurr to charToNum(Lcurr)
  92.       return Lcurr - 64
  93.     end if
  94.   end if
  95. end
  96.  
  97. on hSetGlobalCounter pWhat
  98.   set gGlobalStepCount to pWhat
  99. end
  100.  
  101. on hSetLocalCounter pWhat
  102.   set gLocalStepCount to pWhat
  103. end
  104.  
  105. on hGetMyAlphaGroupItem pWGC
  106.   if (gModeState = #ENCY) or (gModeState = #EPIS) or (gModeState = #CHRO) or (gModeState = #EPISSUB) then
  107.     set vListStart to mGetMyFirstItem(oIndexMediator)
  108.     set vListEnd to mGetMyMaxItems(oIndexMediator)
  109.     set vFound to 0
  110.     repeat while vFound = 0
  111.       if vListEnd <= (vListStart + 1) then
  112.         set vFound to 1
  113.       end if
  114.       set vCheckPoint to vListStart + ((vListEnd - vListStart) / 2)
  115.       if pWGC > mGetThisItemsMax(oIndexMediator, vCheckPoint) then
  116.         set vListStart to vCheckPoint
  117.         next repeat
  118.       end if
  119.       set vListEnd to vCheckPoint
  120.     end repeat
  121.     if pWGC > vListEnd then
  122.       set pWGC to vListEnd
  123.     end if
  124.     return vListEnd
  125.   else
  126.     return 1
  127.   end if
  128. end
  129.  
  130. on hUpdateCurrItem pToThis
  131.   if (gModeState = #CHRO) and (length(pToThis) <> 2) then
  132.     beep()
  133.   end if
  134.   if (gModeState <> #CHRO) and (length(pToThis) <> 1) then
  135.     beep()
  136.     mSetCurrItem(oIndexMediator, pToThis)
  137.   end if
  138.   if not (gModeState = #EPISSUB) then
  139.     if gModeState <> #CHRO then
  140.       mSetCurrItem(oIndexMediator, hConvertAlphaToItem(hCapitalize(pToThis)))
  141.     else
  142.       mSetCurrItem(oIndexMediator, pToThis)
  143.     end if
  144.   else
  145.   end if
  146. end
  147.  
  148. on hSetIncomingCurrItem pThePgPtr
  149.   mSetCurrItem(oIndexMediator, hGetMyAlphaGroupItem(pThePgPtr))
  150. end
  151.